/*
* @Author: Administrator
* @Date:   2019-08-18 11:49:38
* @Last Modified by:   Administrator
* @Last Modified time: 2019-08-18 14:16:51
*/
var express = require('express');
var app = express();





var path = require('path');


// 路由模块
var router = require('./routes/index.js');


// session 模块
var cookieSession = require('cookie-session')
app.use(cookieSession({
  name: 'sessionId',
  keys: ['fGHJKL45678fgHJK$%^&*(Lorem ipsum dolor sit amet, consectetur.']
}));

var bodyParser = require('body-parser')
app.use(bodyParser.urlencoded({ extended: false }))
app.use(bodyParser.json())


// 1. 写在配置session之后， 2. 路由之前
app.use(function (request, response, next) {

	app.locals.userInfo = request.session.userInfo;
	next();

})





// 配置模板引擎
app.engine('html', require('express-art-template'))
// 配置模板目录
app.set('views', path.resolve(__dirname, 'templates'));

app.set('view engine', 'html');


app.get('/member',function(req,res){
	res.redirect('/profile');
});



app.use(router);

app.listen(8080, function () {
	console.log( 'server running...' );
})